class Game{
	constructor(select){
		this.map=document.querySelector(select)
		this.food=new Food(select)
		this.snake=new Snake(select)
		this.timer=0
		this.speed = 120
		//this.start()
	}
	start(){
		this.timer = setInterval(() => {
			this.snake.move()
			this.snake.isBaller()
			if(this.snake.isEat(this.food.x,this.food.y)){
				this.snake.creatHead()
				this.food.foodPos()
				this.speed = this.speed - 10
			}
			if(this.snake.isDie()){
				clearInterval(this.timer)
				this.speed = 10000
			}
		},this.speed);
	}
	pause(){
		clearInterval(this.timer)
	}
	restart(){
		window.location.reload()
	}
	change(type){
		this.snake.direction = type
	}
	getKey(){
		return  this.snake.direction
	}
}